Merge pull request #208 from knu/tweet_id

Include tweet_id in payload for each successful tweet.

Andrew Cantino 10 年之前
父節點
當前提交
e73223476f
共有 2 個文件被更改,包括 7 次插入3 次删除
  1. 2 1
      app/models/agents/twitter_publish_agent.rb
  2. 5 2
      spec/models/agents/twitter_publish_agent_spec.rb

+ 2 - 1
app/models/agents/twitter_publish_agent.rb

@@ -43,10 +43,11 @@ module Agents
43 43
       incoming_events.each do |event|
44 44
         tweet_text = Utils.value_at(event.payload, options['message_path'])
45 45
         begin
46
-          publish_tweet tweet_text
46
+          tweet = publish_tweet tweet_text
47 47
           create_event :payload => {
48 48
             'success' => true,
49 49
             'published_tweet' => tweet_text,
50
+            'tweet_id' => tweet.id,
50 51
             'agent_id' => event.agent_id,
51 52
             'event_id' => event.id
52 53
           }

+ 5 - 2
spec/models/agents/twitter_publish_agent_spec.rb

@@ -22,7 +22,10 @@ describe Agents::TwitterPublishAgent do
22 22
     @event.save!
23 23
 
24 24
     @sent_messages = []
25
-    stub.any_instance_of(Agents::TwitterPublishAgent).publish_tweet { |message| @sent_messages << message}
25
+    stub.any_instance_of(Agents::TwitterPublishAgent).publish_tweet { |message|
26
+      @sent_messages << message
27
+      OpenStruct.new(:id => 454209588376502272)
28
+    }
26 29
   end
27 30
 
28 31
   describe '#receive' do
@@ -53,4 +56,4 @@ describe Agents::TwitterPublishAgent do
53 56
       @checker.reload.should_not be_working # More time has passed than the expected receive period without any new events
54 57
     end
55 58
   end
56
-end
59
+end